<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/jquery-1.10.1.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html,
        body {
            height: 5000px;
        }

        .box {
            position: fixed;
        }
    </style>
</head>

<body>
    <div class="box">
        <button>get</button>
        <button>set</button>
    </div>
</body>
<script>
    // $(ele).scrollTop()    获取和设置 滚动条 距离元素顶部的位置
    // document.documentElement.scrollTop
    $("button:contains('get')").click(function () {
        console.log($(document).scrollTop());
    });

    $("button:contains('set')").click(function () {
        $(document).scrollTop(0)
    });


</script>

</html>